<?php

class CConfig extends Zend_Db_Table{
	
	protected $_name;
	
	protected $_primary;
	
	public function _setup(){
		
		$this->_name=R_PRE."configs";
		
		$this->_primary="configid";
		
		parent::_setup();
		
	}


	public function editConfig($name,$data){
		
		$db=$this->getAdapter();
		
		$where = $db->quoteInto('name = ?', $name);

		$rows_affected=$db->update($this->_name,$data,$where);
		
		if($rows_affected!=1){
			
			return false;
			
		}else{
			
			return true;
			
		}
		
		
	}
	
	public function getByName($name)
	{
		return $this->fetchRow(array('name = ?'=>$name));
	}
	
	public function getDetail($configid){
		
		$db=$this->getAdapter();
		
		$select = $db->select();

		$select->from($this->_name,'*');
		
		$select->where('configid = ? ',$configid);
		
		return $db->fetchAll($select);
		
	}
	
	public function getAllConfigs(){
		
		$db=$this->getAdapter();
		
		$select = $db->select();
		
		$select->from($this->_name,'*');
		
		return $db->fetchAll($select);
		
	}
	

	
	

	
}